package com.vodafone.mapreduce.map;

/**
 * TODO: Insert your comments here!
 */
public class WordFrequencyMapFunction extends MapFunction<String, String, String, Integer> {

    @Override
    protected void doMap(String k, String v) {
        // We expect that K and V are set to String.
        log.debug("Count each word in the passed document now...");
        String[] tokens = v.split("( |,|\n|\\?|!|\\.|\\(|\\))+");
        log.debug("Found these words:");
        for (String token : tokens) {
            log.debug("'" + token + "'");
            emitIntermediate(token, 1);
        }
    }

}
